package jjn.round2;

/**
 * @author Jiang Jining
 * @since 2023-05-03 13:27
 */
public class Offer63_BestTimeToBuyAndSellStock {
    public int maxProfit(int[] prices) {
        int cost = Integer.MAX_VALUE, profit = 0;
        for (int price : prices) {
            cost = Math.min(cost, price);
            profit = Math.max(profit, price - cost);
        }
        return profit;
    }
}
